package com.example.test

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.PersistableBundle
import android.util.Log
import androidx.activity.viewModels
import com.example.test.databinding.ActivityMainBinding
import kotlinx.coroutines.*

class MainActivity : AppCompatActivity() {
   lateinit var  bing :ActivityMainBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.i("TAG", "===>>> onCreate")
        bing = ActivityMainBinding.inflate(layoutInflater)
        val model: ViewModelWithLiveData by viewModels()
        setContentView(bing.root)

    }

    override fun onStart() {
        super.onStart()
        Log.i("TAG", "===>>> onStart")
    }

    override fun onResume() {
        super.onResume()
        Log.i("TAG", "===>>> onResume")

    }

    override fun onPause() {
        super.onPause()
        Log.i("TAG", "===>>> onPause")
    }

    override fun onStop() {
        super.onStop()
        Log.i("TAG", "===>>> onStop")
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.i("TAG", "===>>> onDestroy")
    }

    override fun onRestart() {
        super.onRestart()
        Log.i("TAG", "===>>> onRestart")
    }

    override fun finish() {
        Log.i("TAG", "===>>> finish")
        super.finish()
    }

    override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
        super.onSaveInstanceState(outState, outPersistentState)
        Log.i("TAG", "===>>> onSaveInstanceState")
    }

    override fun onBackPressed() {
      //  super.onBackPressed()
        finish()
    }


}
/*private fun launchFromGlobalScope() {
    Log.i("hugea", "delay:前前面 ")
    GlobalScope.launch() {
        val deferred = async(Dispatchers.Main) {
            // network request
            Log.i("hugea", "delay:前面 ")
            delay(3000)
            "Get it"
            Log.i("hugea", "delay:后面 ")
        }

    }
    Log.i("hugea", "delay:外面 ")
}*/
